package com.powerwyx.shortlink.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.powerwyx.shortlink.project.pojo.dto.ShortLinkPageDTO;
import com.powerwyx.shortlink.project.pojo.entity.Link;
import com.powerwyx.shortlink.project.pojo.vo.ShortLinkCountVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 17585
 * @description 针对表【t_link】的数据库操作Mapper
 * @createDate 2024-07-05 21:26:37
 * @Entity generator.domain.TLink
 */
public interface LinkMapper extends BaseMapper<Link> {

    List<ShortLinkCountVO> getGroupShortLinkCount(List<String> gids);



    @Update("update t_link set " +
            "total_pv = total_pv + #{totalPv},total_uv =total_uv + #{totalUv},total_uip = total_uip + #{totalUip}" +
            " where gid = #{gid} and full_short_url = #{fullShortUrl}")
    void incrementStats(@Param("gid") String gid, @Param("fullShortUrl") String fullShortUrl, @Param("totalPv") Integer totalPv, @Param("totalUv") Integer totalUv, @Param("totalUip") Integer totalUip);


    IPage<Link> pageLink(ShortLinkPageDTO shortLinkPageDTO);

}




